package com.ruoyi.yanjing.common;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import com.ruoyi.common.utils.StringUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
/**
 *
 * @author
 *
 */
public class DateUtil {
	public static String[] MONTHS = new String[]{"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};

	private static int[] DOMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	private static int[] lDOMonth = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

	public static final String YMD_YEAR = "yyyy";
	public static final String MD = "MM-dd";
	public static final String YMD_A = "yyyy-MM-dd";
	public static final String YMD_B = "yyyy/MM/dd";
	public static final String YMD_C = "yyyyMMdd";
	public static final String SFM_C = "HHmmss";
	public static final String YMD_D = "yyyyMMdd";
	public static final String YMD_E = "yyMMdd";

	public static final String YMDHMS_A = "yyyy-MM-dd HH:mm:ss";
	public static final String YMDHMS_B = "yyyy/MM/dd HH:mm:ss";
	public static final String YMDHMS_C = "yyyy.MM.dd HH:mm:ss";
	public static final String YMDHMSS_A = "yyyy-MM-dd HH:mm:ss.SSS";
	public static final String YMDHMSS_B = "yyyy/MM/dd HH:mm:ss.SSS";
	public static final String YMDHMSS_C = "yyyy.MM.dd HH:mm:ss.SSS";
	public static final String YMDHMSS_ZH = "yyyy年MM月dd日 HH时mm分ss秒";

	public static final String FMT_ZH_DAY = "yyyy-MM-dd";
	public static final String FMT_ZH_SFM = "HH:mm:ss";
	public static final String FMT_ZH_HOUR = "yyyy-MM-dd HH";
	public static final String FMT_ZH_MIN = "yyyy-MM-dd HH:mm";
	public static final String FMT_ZH_SEC = "yyyy-MM-dd HH:mm:ss";
	public static final String FMT_ZH_SSS = "yyyy-MM-dd HH:mm:ss.SSS";
	public static final String ALL_FMT_ZH_SSS = "yyyyMMddHHmmssSSS";
	public static final String ALL_FMT_ZH = "yyyyMMddHHmmss";

	/**
	 * 取年.
	 * @param date
	 * @return
	 */
	public static String getYear(Date date) {
		String str = null;
		if (date != null) {
			str = DateFormatUtils.format(date, "yyyy");
		}
		return str;
	}

	/**
	 * 格式化时间.
	 * @param date
	 * @param fmt
	 * @return
	 */
	public static String format(Date date, String fmt) {
		if (date == null) {
			return null;
		}
		SimpleDateFormat sdf = new SimpleDateFormat(fmt);
		return sdf.format(date);
	}

	/**
	 * 取日期是月份.
	 * @param date
	 * @return
	 */
	public static int getMonth(Date date) {
		Calendar cal =Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.MONTH, 1);
		Object day= cal.get(Calendar.MONTH);
		if(day != null) {
			return Integer.valueOf(day.toString());
		} else {
			return 0;
		}
	}

	/**
	 * 取日期是一个月中的几号.
	 * @param date
	 * @return
	 */
	public static int getDay(Date date) {
		Calendar cal =Calendar.getInstance();
		cal.setTime(date);
		Object day= cal.get(Calendar.DATE);
		if(day != null) {
			return Integer.valueOf(day.toString());
		} else {
			return 0;
		}
	}

	/**
	 * 判断两个时间的大小.
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	public static boolean isCompareTime(Date startTime,Date endTime){
		if(endTime.getTime() > startTime.getTime()){
			return true;
		}else{
			return false;
		}
	}


	public static int getDaysOfmonth(int month) {
		Calendar cal =Calendar.getInstance();
		cal.set(Calendar.MONTH, month);
		if ((cal.get(Calendar.YEAR) % 4) == 0) {
			if ((cal.get(Calendar.YEAR) % 100) == 0
					&& (cal.get(Calendar.YEAR) % 400) != 0)
				return DOMonth[cal.get(Calendar.MONTH)];
			return lDOMonth[cal.get(Calendar.MONTH)];
		} else
			return DOMonth[cal.get(Calendar.MONTH)];
	}

	public static Calendar getClearCalendar() {
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.HOUR_OF_DAY, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MILLISECOND, 0);
		return cal;
	}

	public static Date getDateAfterDays(Date date, int duration) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.DATE, duration);
		return cal.getTime();
	}

	public static Date getDateBeforeHours(Date date, int duration) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.HOUR_OF_DAY, -duration);
		return cal.getTime();
	}

	public static Date getDateAfterMinutes(long duration) {
		long curr = System.currentTimeMillis();
		curr = curr+duration*60*1000;
		return new Date(curr);
	}

	public static String formatDate(Date date,String format) {
		return getFormatDate( date, format);
	}

	/**
	 * 格式时间
	 * @param date
	 * @param format
	 * @return
	 */
	public static String getFormatDate(Date date,String format){
		if(date!=null){
			SimpleDateFormat f = new SimpleDateFormat(format);
			f.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); // 设置时区
			return f.format(date);
		}else {
			return null;
		}
	}

	public static String getZHDay(Date date){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		switch (calendar.get(Calendar.DAY_OF_WEEK)) {
		case Calendar.MONDAY:
			return "星期一";
		case Calendar.TUESDAY:
			return "星期二";
		case Calendar.WEDNESDAY:
			return "星期三";
		case Calendar.THURSDAY:
			return "星期四";
		case Calendar.FRIDAY:
			return "星期五";
		case Calendar.SATURDAY:
			return "星期六";
		case Calendar.SUNDAY:
			return "星期日";
		default:
			return "";
		}
	}

	/**
	 * 根据date来获取该时间在传入的iniTime中的位置   formatDateIndex(newDate,"2021-08-01 12:34:12");
	 * @param date 格式时间  String time = "2021-09-01 12:13:14";
	 * @param iniTime 初始时间
	 * @return
	 */
	public static List<String> formatDateIndex(Date date,String iniTime){
		List<String> strList = new ArrayList<String>();
		String fmtTime = format(date, YMDHMS_A);
		Long year = Long.valueOf(fmtTime.substring(0, 4));
		Long month = Long.valueOf(fmtTime.substring(5, 7));
		Long day = Long.valueOf(fmtTime.substring(8, 10));
		Long hour = Long.valueOf(fmtTime.substring(11, 13));
		Long min = Long.valueOf(fmtTime.substring(14, 16));
		Long sec = Long.valueOf(fmtTime.substring(17, 19));

		Long fmtyear = Long.valueOf(iniTime.substring(0, 4));
		Long fmtmonth = Long.valueOf(iniTime.substring(5, 7));
		Long fmtday = Long.valueOf(iniTime.substring(8, 10));
		Long fmthour = Long.valueOf(iniTime.substring(11, 13));
		Long fmtmin = Long.valueOf(iniTime.substring(14, 16));
		Long fmtsec = Long.valueOf(iniTime.substring(17, 19));

		String abc = String.valueOf(year-fmtyear)+"-"+String.valueOf(month-fmtmonth)+"-"+String.valueOf(day-fmtday)+
		"-"+String.valueOf(hour-fmthour)+"-"+String.valueOf(min-fmtmin)+"-"+String.valueOf(sec-fmtsec);

		strList = StringUtil.getListByString(abc, "-");
		return strList;
	}
//	YMDHMS_A



	/**
	 * 当前日期小时相加或相减所得日期（+,-）操作,输入一个日期得到天数加减后的日期。
	 * @param cal
	 * @return
	 */
	public static Date DsDay_Hour(Date date,Integer hours){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.HOUR, hours);

		return cal.getTime();
	}

	/**
	 * 把参数时间精确到天
	 * @param cal
	 * @return
	 */

	public static Date accurateToDay(Date date){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return clearDateAfterDay(cal);
	}

	public static int getDayOfWeek(Calendar cal){//得到每月1号是星期几
		cal.set(Calendar.DATE, 1);
		return cal.get(Calendar.DAY_OF_WEEK);
	}

	/**
	 * 根据格式获取日期字符串.
	 * @param format
	 * @param aDate
	 * @return
	 */
	public static String getDateTime(Date aDate,String format) {
		SimpleDateFormat df = new SimpleDateFormat(format);
		String returnValue = df.format(aDate);
		return returnValue;
	}
	/**
	 * 当前日期分钟相加或相减所得日期（+,-）操作,输入一个日期得到天数加减后的日期。
	 *
	 * @param months
	 * @return
	 */
	public static Date DsDay_Minute(Date date, int minute) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int minutes = calendar.get(Calendar.MINUTE);
		calendar.set(Calendar.MINUTE, minutes + minute);
		return calendar.getTime();
	}

	/**
	 * 清理所有天后面的日期时间
	 * @param c
	 * @return
	 */
	public static Date clearDateAfterDay(Calendar c){
		c.set(Calendar.MILLISECOND, 0);
		c.set(Calendar.SECOND, 0);
		c.set(Calendar.MINUTE, 0);
		c.set(Calendar.HOUR_OF_DAY, 0);
		return c.getTime();
	}
	/**
	 * String转Date
	 * @param sdate 日期字符串
	 * @param fmString 指定日期格式
	 * @return
	 */
	public static Date toDate(String sdate, String fmString) {
		DateFormat df = new SimpleDateFormat(fmString);
		try {
			return df.parse(sdate);
		} catch (ParseException e) {
			throw new RuntimeException("日期格式不正确 ");
		}
	}
	/**
	 * 根据出生日期得到年龄
	 */
	public static int getAge(Date birthDay){
        Calendar cal = Calendar.getInstance();

        if (cal.before(birthDay)) {
           return 0;
        }

        int yearNow = cal.get(Calendar.YEAR);
        int monthNow = cal.get(Calendar.MONTH)+1;//注意此处，如果不加1的话计算结果是错误的
        int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
        cal.setTime(birthDay);

        int yearBirth = cal.get(Calendar.YEAR);
        int monthBirth = cal.get(Calendar.MONTH)+1;
        int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);

        int age = yearNow - yearBirth;
        if(monthNow<monthBirth ||(monthNow==monthBirth && dayOfMonthNow < dayOfMonthBirth)){
        	age--;
        }
        return age;
    }

	// 计算两个日期之间有多少天
	public static int getDaysBetween(Date startDate, Date endDate) {
		Calendar d1 = Calendar.getInstance();
		d1.setTime(startDate);
		Calendar d2 = Calendar.getInstance();
		d2.setTime(endDate);
		if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end
			Calendar swap = d1;
			d1 = d2;
			d2 = swap;
		}
		int days = d2.get(Calendar.DAY_OF_YEAR) - d1.get(Calendar.DAY_OF_YEAR);
		int y2 = d2.get(Calendar.YEAR);
		if (d1.get(Calendar.YEAR) != y2) {
			d1 = (Calendar) d1.clone();
			do {
				days += d1.getActualMaximum(Calendar.DAY_OF_YEAR);// 得到当年的实际天数
				d1.add(Calendar.YEAR, 1);
			} while (d1.get(Calendar.YEAR) != y2);
		}
		return days;
	}

	/**
	 * 当前日期相加或相减所得日期（+,-）操作
	 *
	 * @param months
	 * @return Date
	 */
	public static Date dsDay_Date(Date date,int day) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int days = calendar.get(Calendar.DATE);
		calendar.set(Calendar.DATE, days + day);
		Date cc = calendar.getTime();
		return cc;
	}

	/**
	 * 当前日期相加或相减所得日期（+,-）操作
	 *
	 * @param months
	 * @return Date
	 */
	public static Date dsMonth_Date(Date date,int month) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int months = calendar.get(Calendar.MONTH);
		calendar.set(Calendar.DATE, months + month);
		Date cc = calendar.getTime();
		return cc;
	}

	/**
	 * 当前日期相加或相减所得日期（+,-）操作
	 *
	 * @param months
	 * @return Date
	 */
	public static Date dsYear_Date(Date date,int year) {
		Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.YEAR, 1);
        date = calendar.getTime();
		return date;
	}


	/**
	 * 两个时间间的日期LIST.
	 * @param beginDate
	 * @param endDate
	 * @return
	 */
	public static List<Date> getDateList(Date beginDate,Date endDate){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(beginDate);
		List<Date> dateList = new ArrayList<Date>();

		dateList.add(beginDate);

		while(true){
			if(clean(beginDate).equals(endDate)){
				break;
			}
			calendar.add(Calendar.DATE, 1);
			Date currentDate = calendar.getTime();
			dateList.add(currentDate);
			if(currentDate.after(endDate)||clean(currentDate).equals(clean(endDate))){
				break;
			}

		}
		return dateList;
	}


	private static Date clean(Date date){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		return calendar.getTime();
	}

	public static Date getAfterDay(Date date){
		SimpleDateFormat simpleOldDate=new SimpleDateFormat("yyyy-MM-dd 00:00:00");
		Calendar ca=Calendar.getInstance();
		try {
			ca.setTime(simpleOldDate.parse(simpleOldDate.format(date)));
		} catch (ParseException e) {
			ca.setTime(getDayStart(new Date()));
		}
		ca.add(Calendar.DATE, 1);
		return ca.getTime();

	}


	 /**
     * 获取当月开始时间戳
     *
     * @param timeStamp 毫秒级时间戳
     * @param timeZone  如 GMT+8:00
     * @return
     */
    public static Date getMonthStartTime(Date date) {
    	if(date==null)
			return null;
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
        calendar.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }

    /**
     * 获取当月的结束时间戳
     *
     * @param timeStamp 毫秒级时间戳
     * @param timeZone  如 GMT+8:00
     * @return
     */
    public static Date getMonthEndTime(Date date) {
    	if(date==null)
			return null;
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));// 获取当前月最后一天
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        return calendar.getTime();
    }



	/**
	 * 返回 该日期的开始处
	 * @param date
	 * @return
	 */
	public static Date getDayStart(Date date){
		if(date==null)
			return null;
		Calendar c=Calendar.getInstance();
		c.setTime(date);
		c.set(Calendar.HOUR_OF_DAY, 0);
		c.set(Calendar.MINUTE, 0);
		c.set(Calendar.SECOND, 0);
		c.set(Calendar.MILLISECOND, 0);
		return c.getTime();
	}

	public static Date getDayEnd(Date date){
		if(date==null)
			return null;
		Calendar c=Calendar.getInstance();
		c.setTime(date);
		c.set(Calendar.HOUR_OF_DAY, 23);
		c.set(Calendar.MINUTE, 59);
		c.set(Calendar.SECOND, 59);
		c.set(Calendar.MILLISECOND, 999);
		return c.getTime();
	}
	/**
	 * 得到当前时间的23点.
	 * @param date
	 * @return
	 */
	public static Date getDayEndBeforeOneH(Date date) {
		if(date==null)
			return null;
		Calendar c=Calendar.getInstance();
		c.setTime(date);
		c.set(Calendar.HOUR_OF_DAY, 23);
		c.set(Calendar.MINUTE, 00);
		c.set(Calendar.SECOND, 00);
		c.set(Calendar.MILLISECOND, 000);
		return c.getTime();
	}

	/**
	 * date1是否早于date2
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static boolean inAdvance(Date date1, Date date2) {
		return date1.getTime()<date2.getTime();
	}

	/**
	 * 将日期和时分的两个时间合并到一起
	 *
	 * @param date
	 * @param time
	 * @return
	 */
	public static Date mergeDateTime(Date date, Date time) {
		Calendar dateCalendar = Calendar.getInstance();
		dateCalendar.setTime(date);
		Calendar timeCalendar = Calendar.getInstance();
		timeCalendar.setTime(time);
		dateCalendar.set(Calendar.HOUR, timeCalendar.get(Calendar.HOUR));
		dateCalendar.set(Calendar.MINUTE, timeCalendar.get(Calendar.MINUTE));
		dateCalendar.set(Calendar.SECOND, timeCalendar.get(Calendar.SECOND));
		return dateCalendar.getTime();
	}

	/**
	 * 字符型时间(Long)转换成时间格式的日期.
	 * @param dateLong
	 * @return
	 */
	public static Date formatStringToDate(Long dateLong) {
		Date dt = new Date(dateLong);
		return dt;
	}

	/**
	 * 字符型时间转换成时间格式的日期.
	 * @param dateStr
	 * @param formate
	 * @return
	 */
	public static Date getDateByStr(String dateStr, String formate) {
		SimpleDateFormat sdf = new SimpleDateFormat(formate);
		Date date = null;
		try {
			date = sdf.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}

	/**
	 * 字符串转换到时间格式
	 * @param dateStr 需要转换的字符串
	 * @param formatStr 需要格式的目标字符串  举例 yyyy-MM-dd
	 * @return Date 返回转换后的时间
	 * @throws ParseException 转换异常
	 */
	public static Date stringToDate(String dateStr,String formatStr){
		DateFormat sdf=new SimpleDateFormat(formatStr);
		Date date=null;
		try {
			date = sdf.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
	/**
	 * 比较2个日期 前一个日期至少比后一个日期大一天以上
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static boolean compareDateLessOneDayMore(Date date1,Date date2){
		Calendar c1 = Calendar.getInstance();
		c1.setTime(date1);
		Calendar c2 = Calendar.getInstance();
		c2.setTime(date2);
		if(c1.get(Calendar.YEAR)>=c2.get(Calendar.YEAR)&&c1.get(Calendar.MONTH)>=c2.get(Calendar.MONTH)&&c1.get(Calendar.DATE)>c2.get(Calendar.DATE)){
			return true;
		}
		return false;

	}

	/**
	 * 获取两个时间点中间的小时数.
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public static Long getHourBetween(Date startDate, Date endDate) {
		Calendar d1 = Calendar.getInstance();
		d1.setTime(startDate);
		Calendar d2 = Calendar.getInstance();
		d2.setTime(endDate);
		Long min = 0L;
		if(d1.getTimeInMillis() > d2.getTimeInMillis()){
			min = (d1.getTimeInMillis()-d2.getTimeInMillis())/(1000*60*60);
		}else{
			min = (d2.getTimeInMillis()-d1.getTimeInMillis())/(1000*60*60);
		}
		return min;
	}

	/**
	 * 获取两个时间点中间的分钟数.
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public static Long getMinBetween(Date startDate, Date endDate) {
		Calendar d1 = Calendar.getInstance();
		d1.setTime(startDate);
		Calendar d2 = Calendar.getInstance();
		d2.setTime(endDate);
		Long min = 0L;
		if(d1.getTimeInMillis() > d2.getTimeInMillis()){
			min = (d1.getTimeInMillis()-d2.getTimeInMillis())/(1000*60);
		}else{
			min = (d2.getTimeInMillis()-d1.getTimeInMillis())/(1000*60);
		}
		return min;
	}

	/**
	 * 获取两个时间点中间的秒数.
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public static Long getSecondBetween(Date startDate, Date endDate) {
		Calendar d1 = Calendar.getInstance();
		d1.setTime(startDate);
		Calendar d2 = Calendar.getInstance();
		d2.setTime(endDate);
		Long min = 0L;
		if(d1.getTimeInMillis() > d2.getTimeInMillis()){
			min = (d1.getTimeInMillis()-d2.getTimeInMillis())/(1000);
		}else{
			min = (d2.getTimeInMillis()-d1.getTimeInMillis())/(1000);
		}
		return min;
	}


	/**
	 * 获取今天的日期，去掉时、分、秒
	 * @return
	 */
	public static Date getTodayDate(){
		return stringToDate(formatDate(new Date(), "yyyy-MM-dd"), "yyyy-MM-dd");
	}

	/**
	 * 获取今天的日期，去掉时、分、秒
	 * @return
	 */
	public static String getTodayDateString(){
		Date date = new Date();
		String dateStr = getYear(date)+"年"+getMonth(date)+"月"+getDay(date)+"日    "+getZHDay(date);
		return  dateStr;
	}

	/**
	 * 获取今天的日期，去掉时、分、秒
	 * @return
	 */
	public static String getDateString(Date date){
		String dateStr = getYear(date)+"年"+getMonth(date)+"月"+getDay(date)+"日   ";
		return  dateStr;
	}

	/**
	 * 判断两个日期是不是同一天.
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static boolean  isOneDay(Date date1,Date date2){
		return DateUtil.getDayStart(date1).getTime() == DateUtil.getDayStart(date1).getTime();
	}

	/***************CTI start*******************************************/
	/**
	 * 相除(进位).
	 * @param times
	 * @param costMode
	 * @return
	 */
	public static Long formatTimesToString(Long times,Long costMode){
		Long seconds = 0L;
		if(times > 0 && costMode > 0){
			seconds = times%costMode==0?times/costMode:times/costMode+1;
		}else{
			seconds = times;
		}
		return seconds;
	}
	/**
	 * 取时间的秒数 (进位).
	 * @param time
	 * @return
	 */
	public static Long formatSecondsTimeToString(Long time){
		Long seconds = 0L;
		if(time > 0){
			seconds = time%1000==0?time/1000:time/1000+1;
		}
		return seconds;
	}

	/**
	 * 根据时间(日期=年月日时分秒的LongTime).
	 * @param time
	 * @return
	 */
	public static String formatTimeToString(Long time){
		String dateString = "00:00:00";
		if(time!=null &&  time > 0){
			Long hours = time/60/60/1000;
			time = time - hours*60*60*1000;
			Long mis = time/60/1000;
			time = time - mis*60*1000;
			Long seconds = time%1000==0?time/1000:time/1000+1;
			if(seconds == 60L){
				mis = mis+1L;
				seconds=0L;
			}
			if(mis == 60L){
				hours = hours+1L;
				mis = 0L;
			}
			dateString = getId(hours.toString())+":"+ getId(mis.toString())+":"+ getId(seconds.toString());
		}
		return dateString;
	}

	/**
	 *
	 * @param id
	 * @return
	 */
	public static String getId(String id) {
		String buID = "";
		if (id.length() == 1) {
			buID = "0" + id;
		}else{
			buID = id;
		}
		return buID;
	}
	/***************CTI end*******************************************/


	public static void main(String args[]) throws ParseException {

		Date newDate = new Date();
		String time = "2022-02-11 12:13:14";
		Date date = stringToDate(time,YMDHMS_A);
//		formatDateIndex(date,"2021-01-01 01:01:01");

		System.out.println("getMonthStartTime="+DateUtil.format(DateUtil.getMonthStartTime(date),DateUtil.YMDHMS_A));
		System.out.println("getMonthEndTime="+DateUtil.format(DateUtil.getMonthEndTime(date),DateUtil.YMDHMS_A));


//		Long newTimeLong = newDate.getTime();
//		System.out.println(newTimeLong);
//
//		Date date = formatStringToDate(newTimeLong);
//		String time = format(date,YMDHMS_A);
//		System.out.println(time);
//
//		System.out.println(newTimeLong/1000L);

	}


}
